﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

using CodeDeeds.Debug;
using CodeDeeds.Reflection.Cloning;

namespace CloneFactoryTest
{
   class Program
   {
      private static Person burgerJoe = new Person()
      {
         FirstName = "Joe",
         LastName = "White",
         NickName = "Burger Joe",
         DateOfBirth = new DateTime(1971,1,1)
      };

      private static Person giJane = new Person()
      {
         FirstName = "Jane",
         LastName = "White",
         NickName = "GI Jane",
         DateOfBirth = new DateTime(1971, 5, 17)
      };

      private static Person babyWiliam = new Person()
      {
         FirstName = "Wiliam",
         LastName = "White",
         NickName = "Baby Wiliam",
         DateOfBirth = new DateTime(1971, 1, 1)
      };

      private static Person babyEllen = new Person()
      {
         FirstName = "Ellen",
         LastName = "White",
         NickName = "Baby Ellen",
         DateOfBirth = new DateTime(1971, 5, 17)
      };

      private static Person oldBob = new Person()
      {
         FirstName = "Bob",
         LastName = "White",
         NickName = "Old Bob",
         DateOfBirth = new DateTime(1938, 3, 15)
      };

      private static Person oldKate = new Person()
      {
         FirstName = "Kate",
         LastName = "White",
         NickName = "Old Kate",
         DateOfBirth = new DateTime(1942, 8, 8)
      };

      private static Person oldArnold = new Person()
      {
         FirstName = "Arnold",
         LastName = "Brown",
         NickName = "Old Arnold",
         DateOfBirth = new DateTime(1940, 4, 15)
      };

      private static Person oldAmber = new Person()
      {
         FirstName = "Amber",
         LastName = "Brown",
         NickName = "Old Amber",
         DateOfBirth = new DateTime(1944, 5, 8)
      };

      static Program()
      {
         burgerJoe.Spouse = giJane;
         giJane.Spouse = burgerJoe;
         burgerJoe.Father = oldBob;
         burgerJoe.Mother = oldKate;
         giJane.Mother = oldAmber;
         giJane.Father = oldArnold;
         burgerJoe.Children.Add(babyWiliam);
         burgerJoe.Children.Add(babyEllen);
         giJane.Children.Add(babyWiliam);
         giJane.Children.Add(babyEllen);
         babyEllen.Mother = giJane;
         babyEllen.Father = burgerJoe;
         babyWiliam.Mother = giJane;
         babyWiliam.Father = burgerJoe;

         oldBob.Spouse = oldKate;
         oldBob.Children.Add(burgerJoe);
         oldKate.Spouse = oldBob;
         oldKate.Children.Add(burgerJoe);

         oldArnold.Spouse = oldAmber;
         oldArnold.Children.Add(giJane);
         oldAmber.Spouse = oldArnold;
         oldAmber.Children.Add(giJane);
      }

      static void Main(string[] args)
      {
         Console.WriteLine();
         Person clone; // = CloneFactory.MakeDeepClone(burgerJoe);

         PerformanceTest.Meassure(() =>
         {
            clone = CloneFactory.MakeShallowClone(burgerJoe);
         }, 1000000, "Person shallow clone test", Console.Out);

         Console.WriteLine();
         
         PerformanceTest.Meassure(() =>
         {
            clone = CloneFactory.MakeDeepClone(burgerJoe);
         }, 1000000, "Person deep clone test", Console.Out);

         Console.WriteLine();
         Console.ReadKey();
      }
   }
}
